package com.situ.mvc.controller.text;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.jsp.PageContext;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.situ.mvc.entity.Student;

@Controller
@RequestMapping(value="json")
public class JsonController {
	//不转发不重定向，直接在页面打印json数据
	//打印json数据必须加 @ResponseBody 
	
	@RequestMapping(value="list")
	@ResponseBody 
	public List<Student> list() {
		List<Student> list = new ArrayList<>();
		for (int i = 1; i < 100; i++) {
			Student student = new Student(i,"张" + i, i+10, "男");
			list.add(student);
		}
		return list;
	}
	
	//打印json类型的isExist
	@RequestMapping(value="chack1")
	@ResponseBody
	public boolean check1() {
		boolean isExist = false;
		return isExist;
	}
	
	@RequestMapping(value="check2")
	@ResponseBody
	public Map<String, Object> check2() {
		boolean isExist = false;
		Map<String, Object> map = new HashMap<>();
		map.put("isExist", isExist);
		return map;
	}
}
